// main.js 中内容如下

const { app, BrowserWindow } = require('electron')
const path = require('path')
const NODE_ENV = process.env.NODE_ENV
app.allowRendererProcessReuse = false
const createWindow = () => {
  const win = new BrowserWindow({
    width: 1200,
    height: 800,
	webPreferences:{
		nodeIntegration:true,
		contextIsolation:false,
		enableRemoteModule:true
	}
  })  
  win.loadURL(
  NODE_ENV === 'development'
  ? 'http://localhost:5173'
  :`file://${path.join(__dirname,'../dist/build/h5/index.html')}`
  )
  // 注意: 该路径为uniapp 发行H5/PC后生成的文件路径
  //win.loadURL('http://localhost:5174')//开发环境
  //win.loadFile('dist/build/h5/index.html')//生产环境
  win.webContents.openDevTools() // 开启调试工具
}
app.whenReady().then(() => {
  createWindow()
	app.on('activate', () => {
		if (BrowserWindow.getAllWindows().length === 0) createWindow()
	})
})
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') app.quit()
})
